package com.ggmc;

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.SystemColor;
import java.awt.Font;

public class OutputPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	private String newline = "\n";
	
	private JTextPane txtpnContacts;
	//final Document doc; 
	
	public OutputPanel(String panelTitle)	{
		setBackground(new Color(255, 240, 245));
//		FlowLayout flowLayout = (FlowLayout) getLayout();
//		flowLayout.setAlignment(FlowLayout.LEFT);
		
		setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray), panelTitle));

		// create text output poanel on rhs
		txtpnContacts = new JTextPane();
		add(txtpnContacts);
		
		// create text output poanel on rhs
		txtpnContacts = new JTextPane();
		txtpnContacts.setFont(new Font("Tahoma", Font.PLAIN, 12));
		txtpnContacts.setForeground(new Color(0, 128, 0));
		txtpnContacts.setBackground(new Color(255, 240, 245));
		txtpnContacts.setEditable(false);
		JScrollPane scrollPane = new JScrollPane(txtpnContacts);
	    setLayout(new BorderLayout());
		add(scrollPane);
		
	}

	public void setDisplayContact(String emailAddress)	{
	
        try {
        	Document doc = txtpnContacts.getDocument();
			doc.insertString(doc.getLength(), emailAddress+newline, null);
		} catch (BadLocationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
}
